<template>
  <div class="hello">
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="昵称">
        <el-input v-model="form.nikeName"></el-input>
      </el-form-item>
      <el-form-item label="用户名">
        <el-input v-model="form.userName"></el-input>
      </el-form-item>
      <el-form-item label="密码">
        <el-input type="password" v-model="form.passWord"></el-input>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="onSubmit">立即创建</el-button>
        <el-button>取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
    import axios from 'axios'
export default {
      data() {
        return {
          form: {
            userName: "",
            passWord: "",
            nikeName:""
          }
        }
      },
      methods: {
        onSubmit() {
          console.log(this.form);
          axios.post("http://47.110.234.216:7001/register", {
            username: this.form.userName,
            password: this.form.passWord,
            nikename: this.form.nikeName,
          }).then(res => {
            console.log(res);
            if (res.data.status) {
              this.$message({
                message: '恭喜你，这是一条成功消息',
                type: 'success'
              });
            }
            else {
              this.$message.error('注册失败');
            }
          });

        }
      }
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
  h1, h2 {
    font-weight: normal;
  }

  ul {
    list-style-type: none;
    padding: 0;
  }

  li {
    display: inline-block;
    margin: 0 10px;
  }

  a {
    color: #42b983;
  }
</style>
